<template>
  <div class="app-container">
    <h2>解决方案</h2>
    <search-box
      :fields="searchFeilds"
      @search="handleSearch"
      @add="handleAdd"
    />

    <SearchResult
      uid="getSolutionList"
      ref="searchResult"
      :params="searchParams"
      :ignoreCommand="ignoreCommand"
    >
      <el-table-column label="解决方案名称" align="left">
        <template slot-scope="{row}">
          <span>{{ row.solutionName }}</span>
        </template>
      </el-table-column>

      <el-table-column label="背景图片" align="center">
        <template slot-scope="{row}">
          <span>{{ row.projectBackground }}</span>
        </template>
      </el-table-column>

      <el-table-column label="启用" align="center">
        <template slot-scope="{row}">
          <span>{{ row.isEnable === 1 ? '是' : '否' }}</span>
        </template>
      </el-table-column>

      <!-- <el-table-column label="图标" align="center">
        <template slot-scope="{row}">
          <cImage style="width: 48px; height: 48px" :imageId="row.imageId" fit="contain"></cImage>
        </template>
      </el-table-column> -->

      <el-table-column label="描述" align="center">
        <template slot-scope="{row}">
          <span>{{ row.solutionDescription }}</span>
        </template>
      </el-table-column>
    </SearchResult>
  </div>
</template>
<script>
import { EventBus } from '@/utils/event-bus';
import SearchBox from '@/components/SearchBox';
import SearchResult from '@/components/SearchResult';
import EditSolution from '@/components/DialogComponents/edit-solution';
import cImage from '@/components/Image';
import { getLevelList, isEnableOptions } from '@/utils/config';

export default {
  name: 'solution',
  components: {
    SearchBox,
    SearchResult,
    EditSolution,
    cImage
  },
  data() {
    return {
      searchFeilds: [
        { name: 'SolutionName', label: '解决方案名称', type: 'text' },
        { name: 'IsEnable', label: '是否启用', type: 'list', options: isEnableOptions }
      ],
      ignoreCommand: ['detail'],
      searchParams: {}
    };
  },
  created() {
    EventBus.$emit('custom-breadcrumb', getLevelList(this.$options.name));
  },

  methods: {
    // 搜索
    handleSearch(data) {
      if (data === void 0) data = {};

      this.searchParams = data;
      this.$refs['searchResult'].getData(data);
    },

    // 添加
    handleAdd() {
      this.$refs['searchResult'].handleAdd();
    }
  }
}
</script>
